import requests
if __name__== "__main__":
    # url='https://www.baidu.com/s'
    url='https://image.baidu.com/s'
    pt=input('请输入你要搜索的东西')
    # ua伪装
    headers={
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0'  
        }
    param={
        'word':pt,
        "tn":"baiduimage"
    }
    fl='.\链接爬取\\'+pt+'.html'
    response=requests.get(url=url,params=param,headers=headers)
    with open(fl,'w',encoding='utf-8') as fs:
        fs.write(response.text)
    print('ok')

    # <a href="http://image.baidu.com/i?tn=baiduimage&amp;ps=1&amp;ct=201326592&amp;lm=-1&amp;cl=2&amp;nc=1&amp;ie=utf-8&amp;dyTabStr=MCwxLDMsMiw0LDYsNSw4LDcsOQ%3D%3D&amp;word=789" sync="" wdfield="word" class="s-tab-item s-tab-item_1CwH- s-tab-pic_p4Uej s-tab-pic">图片</a>